package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.dao.UserDao;

import com.baizhi.cmfz.entiy.User;
import com.baizhi.cmfz.service.UserService;
import com.baizhi.cmfz.util.ThreadPollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao dao;


    @Override
    public void update(User user) {
        dao.update(user);
    }

    @Override
    public Map getUserByPage(int page, int rows) {
        HashMap map = new HashMap();
        int total = dao.getTotal();
        map.put("total", total);

        int start=(page-1)*rows;
        int pageSize=rows;
        List<User> list = dao.getUserByPage(start,pageSize);

        map.put("rows", list);
        //System.out.println(map);
        return map;
    }


    @Override
    public List<Map> selectBySexCount() {
        List<Map> list = dao.selectBySexCount();
        return list;
    }

    @Override
    public List<Map> selectByProvince() {
        List<Map> list = dao.selectByProvince();
        return list;
    }


    @Override
    public Map selectByDayCount() {
        HashMap map = new HashMap();
        int[] ints = new int[3];
         ints[0]= dao.selectByDayCount(7,0);
         ints[1]= dao.selectByDayCount(14,7);
         ints[2]= dao.selectByDayCount(21,14);
         map.put("count",map);
        return map;
    }

}
